package com.example.controller;

import com.example.Repository.TrendsRepository;
import com.example.pojo.Result;
import com.example.pojo.dto.TrendsDto;
import com.example.pojo.vo.TrendsVo;
import com.example.utils.ConditionVo;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author crt
 */
@RestController
@RequestMapping("trends")
public class TrendsController {

    @Resource
    private TrendsRepository trendsRepository;

    @PostMapping("/addTrends")
    public Result<String> addTrends(@Valid @RequestBody TrendsDto trendsDto){

        return trendsRepository.addTrends(trendsDto);
    }

    @GetMapping("trendsInfo")
    public Result<TrendsVo> getTrendsInfo(@RequestParam Integer trendsId){
        return trendsRepository.getTrendsInfo(trendsId);
    }

    @PostMapping("trendsList")
    public Result<List<TrendsVo>> getTrendsList(@RequestBody List<ConditionVo> conditionVoList){
        return trendsRepository.getTrendsList(conditionVoList);
    }


    @DeleteMapping("deleteTrends")
    public Result<String> deleteTrends(@RequestParam Integer trendsId){
        return trendsRepository.deleteTrends(trendsId);
    }

}
